package com.cdzs.twocamera.receiver;

import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.cdzs.twocamera.MainActivitySurface;

/**
 * Created by M_genius on 2018/7/6.\
 * 描述:
 * 用于接收开机广播，用于 app 自启动
 */

public class BootReceiver extends BroadcastReceiver {

    private static final String TAG = "BootReceiver";

    public static final String ACTION_BOOT = "android.intent.action.BOOT_COMPLETED";
    private PendingIntent mAlarmSender;

    @Override
    public void onReceive(Context context, Intent intent) {

        if (intent.getAction().equals(ACTION_BOOT)) {

            Log.d(TAG, "onReceive: ");

            Intent startToCameraActivity = new Intent(context, MainActivitySurface.class);
            startToCameraActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(startToCameraActivity);
        }
    }
}
